const express = require("express");
const cors = require("cors");
const router = require("./router");

// 创建服务器对象
const server = express();
server.use(cors());
server.use(express.json());
server.use(express.static("assets"));

// 处理跨域
server.all("*", (req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  next();
});
// 把路由中间件注册到应用中间件上
server.use("/api", router);

// 启动服务器
server.listen(1086, () => {
  console.log("server running at http://127.0.0.1:1085");
});
